// Upgraded to Delphi 2009: Sebastian Zierer

(* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is TurboPower SysTools
 *
 * The Initial Developer of the Original Code is
 * TurboPower Software
 *
 * Portions created by the Initial Developer are Copyright (C) 1996-2002
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *
 * ***** END LICENSE BLOCK ***** *)

{*********************************************************}
{* SysTools: StMars.pas 4.04                             *}
{*********************************************************}
{* SysTools: Astronomical Routines (for Mars)            *}
{*********************************************************}

{$I StDefine.inc}

unit StMars;

interface

uses
  StAstroP;

function ComputeMars(JD : Double) : TStEclipticalCord;


implementation

function GetLongitude(Tau, Tau2, Tau3, Tau4, Tau5 : Double) : Double;
var
  L0, L1,
  L2, L3,
  L4, L5  : Double;
begin
  L0 := 6.20347711580 * cos(0.00000000000 +     0.00000000000 * Tau)
      + 0.18656368100 * cos(5.05037100300 +  3340.61242670000 * Tau)
      + 0.01108216792 * cos(5.40099836960 +  6681.22485340000 * Tau)
      + 0.00091798394 * cos(5.75478745110 + 10021.83728000000 * Tau)
      + 0.00027744987 * cos(5.97049512940 +     3.52311834900 * Tau)
      + 0.00012315897 * cos(0.84956081238 +  2810.92146160000 * Tau)
      + 0.00010610230 * cos(2.93958524970 +  2281.23049650000 * Tau)
      + 0.00008926772 * cos(4.15697845940 +     0.01725365220 * Tau)
      + 0.00008715688 * cos(6.11005159790 + 13362.44970700000 * Tau)
      + 0.00007774867 * cos(3.33968655070 +  5621.84292320000 * Tau)
      + 0.00006797552 * cos(0.36462243626 +   398.14900341000 * Tau)
      + 0.00004161101 * cos(0.22814975330 +  2942.46342330000 * Tau)
      + 0.00003575079 * cos(1.66186540140 +  2544.31441990000 * Tau)
      + 0.00003075250 * cos(0.85696597082 +   191.44826611000 * Tau)
      + 0.00002937543 * cos(6.07893711410 +     0.06731030280 * Tau)
      + 0.00002628122 * cos(0.64806143570 +  3337.08930840000 * Tau)
      + 0.00002579842 * cos(0.02996706197 +  3344.13554500000 * Tau)
      + 0.00002389420 * cos(5.03896401350 +   796.29800682000 * Tau)
      + 0.00001798808 * cos(0.65634026844 +   529.69096509000 * Tau)
      + 0.00001546408 * cos(2.91579633390 +  1751.53953140000 * Tau)
      + 0.00001528140 * cos(1.14979306230 +  6151.53388830000 * Tau)
      + 0.00001286232 * cos(3.06795924630 +  2146.16541650000 * Tau)
      + 0.00001264356 * cos(3.62275092230 +  5092.15195810000 * Tau)
      + 0.00001024907 * cos(3.69334293550 +  8962.45534990000 * Tau)
      + 0.00000891567 * cos(0.18293899090 + 16703.06213300000 * Tau)
      + 0.00000858760 * cos(2.40093704200 +  2914.01423580000 * Tau)
      + 0.00000832724 * cos(4.49495753460 +  3340.62968040000 * Tau)
      + 0.00000832718 * cos(2.46418591280 +  3340.59517300000 * Tau)
      + 0.00000748724 * cos(3.82248399470 +   155.42039943000 * Tau)
      + 0.00000723863 * cos(0.67497565801 +  3738.76143010000 * Tau)
      + 0.00000712899 * cos(3.66336014790 +  1059.38193020000 * Tau)
      + 0.00000655163 * cos(0.48864075176 +  3127.31333130000 * Tau)
      + 0.00000635557 * cos(2.92182704270 +  8432.76438480000 * Tau)
      + 0.00000552746 * cos(4.47478863020 +  1748.01641310000 * Tau)
      + 0.00000550472 * cos(3.81001205410 +     0.98032106820 * Tau)
      + 0.00000472164 * cos(3.62547819410 +  1194.44701020000 * Tau)
      + 0.00000425972 * cos(0.55365138172 +  6283.07585000000 * Tau)
      + 0.00000415132 * cos(0.49662314774 +   213.29909544000 * Tau)
      + 0.00000312141 * cos(0.99853322843 +  6677.70173500000 * Tau)
      + 0.00000306552 * cos(0.38052862973 +  6684.74797180000 * Tau)
      + 0.00000302377 * cos(4.48618150320 +  3532.06069280000 * Tau)
      + 0.00000299396 * cos(2.78323705700 +  6254.62666250000 * Tau)
      + 0.00000293199 * cos(4.22131277910 +    20.77539549200 * Tau)
      + 0.00000283600 * cos(5.76885494120 +  3149.16416060000 * Tau)
      + 0.00000281073 * cos(5.88163372940 +  1349.86740970000 * Tau)
      + 0.00000274035 * cos(0.13372501211 +  3340.67973700000 * Tau)
      + 0.00000274028 * cos(0.54222141841 +  3340.54511640000 * Tau)
      + 0.00000238857 * cos(5.37155471670 +  4136.91043350000 * Tau)
      + 0.00000236114 * cos(5.75504515580 +  3333.49887970000 * Tau)
      + 0.00000231185 * cos(1.28240685290 +  3870.30339180000 * Tau)
      + 0.00000221225 * cos(3.50466672200 +   382.89653222000 * Tau)
      + 0.00000204161 * cos(2.82133266180 +  1221.84856630000 * Tau)
      + 0.00000193126 * cos(3.35715137750 +     3.59042865180 * Tau)
      + 0.00000188639 * cos(1.49103016490 +  9492.14631500000 * Tau)
      + 0.00000179196 * cos(1.00561112570 +   951.71840625000 * Tau)
      + 0.00000174068 * cos(2.41360332580 +   553.56940284000 * Tau)
      + 0.00000172110 * cos(0.43943041719 +  5486.77784320000 * Tau)
      + 0.00000160011 * cos(3.94854735190 +  4562.46099300000 * Tau)
      + 0.00000144305 * cos(1.41874193420 +   135.06508004000 * Tau)
      + 0.00000139897 * cos(3.32592516160 +  2700.71514040000 * Tau)
      + 0.00000138245 * cos(4.30145176910 +     7.11354700080 * Tau)
      + 0.00000130993 * cos(4.04491720260 + 12303.06777700000 * Tau)
      + 0.00000128102 * cos(2.20806651010 +  1592.59601360000 * Tau)
      + 0.00000128062 * cos(1.80665643330 +  5088.62883980000 * Tau)
      + 0.00000116945 * cos(3.12805282210 +  7903.07341970000 * Tau)
      + 0.00000113486 * cos(3.70070798120 +  1589.07289530000 * Tau)
      + 0.00000110375 * cos(1.05195079690 +   242.72860397000 * Tau)
      + 0.00000104541 * cos(0.78535382076 +  8827.39026990000 * Tau)
      + 0.00000100090 * cos(3.24343740860 + 11773.37681200000 * Tau);

  L1 := 3340.85627470000 * cos(0.00000000000 +     0.00000000000 * Tau)
      + 0.01458227051 * cos(3.60426053610 +  3340.61242670000 * Tau)
      + 0.00164901343 * cos(3.92631250960 +  6681.22485340000 * Tau)
      + 0.00019963338 * cos(4.26594061030 + 10021.83728000000 * Tau)
      + 0.00003452399 * cos(4.73210386370 +     3.52311834900 * Tau)
      + 0.00002485480 * cos(4.61277567320 + 13362.44970700000 * Tau)
      + 0.00000841551 * cos(4.45858256760 +  2281.23049650000 * Tau)
      + 0.00000537566 * cos(5.01589727490 +   398.14900341000 * Tau)
      + 0.00000521041 * cos(4.99422678180 +  3344.13554500000 * Tau)
      + 0.00000432614 * cos(2.56066402860 +   191.44826611000 * Tau)
      + 0.00000429656 * cos(5.31646162370 +   155.42039943000 * Tau)
      + 0.00000381747 * cos(3.53881289440 +   796.29800682000 * Tau)
      + 0.00000314129 * cos(4.96335266050 + 16703.06213300000 * Tau)
      + 0.00000282804 * cos(3.15967518200 +  2544.31441990000 * Tau)
      + 0.00000205664 * cos(4.56891455660 +  2146.16541650000 * Tau)
      + 0.00000168805 * cos(1.32894813370 +  3337.08930840000 * Tau)
      + 0.00000157587 * cos(4.18501035950 +  1751.53953140000 * Tau)
      + 0.00000133686 * cos(2.23325104200 +     0.98032106820 * Tau)
      + 0.00000133563 * cos(5.97421903930 +  1748.01641310000 * Tau)
      + 0.00000117591 * cos(6.02407213860 +  6151.53388830000 * Tau)
      + 0.00000116561 * cos(2.21347652540 +  1059.38193020000 * Tau)
      + 0.00000113876 * cos(2.12869455090 +  1194.44701020000 * Tau)
      + 0.00000113595 * cos(5.42803224320 +  3738.76143010000 * Tau)
      + 0.00000091098 * cos(1.09627836590 +  1349.86740970000 * Tau)
      + 0.00000085342 * cos(3.90854841010 +   553.56940284000 * Tau)
      + 0.00000083301 * cos(5.29636626270 +  6684.74797180000 * Tau)
      + 0.00000080776 * cos(4.42813405870 +   529.69096509000 * Tau)
      + 0.00000079531 * cos(2.24864266330 +  8962.45534990000 * Tau)
      + 0.00000072946 * cos(2.50189460550 +   951.71840625000 * Tau)
      + 0.00000072505 * cos(5.84208163240 +   242.72860397000 * Tau)
      + 0.00000071487 * cos(3.85636094440 +  2914.01423580000 * Tau)
      + 0.00000067582 * cos(5.02327686470 +   382.89653222000 * Tau)
      + 0.00000065089 * cos(1.01802439310 +  3340.59517300000 * Tau)
      + 0.00000065089 * cos(3.04879603980 +  3340.62968040000 * Tau)
      + 0.00000061508 * cos(4.15183159800 +  3149.16416060000 * Tau)
      + 0.00000056520 * cos(3.88813699320 +  4136.91043350000 * Tau)
      + 0.00000048477 * cos(4.87362121540 +   213.29909544000 * Tau)
      + 0.00000047613 * cos(1.18238046060 +  3333.49887970000 * Tau)
      + 0.00000046584 * cos(1.31452419910 +  3185.19202730000 * Tau)
      + 0.00000041343 * cos(0.71385375517 +  1592.59601360000 * Tau)
      + 0.00000040272 * cos(2.72542480610 +     7.11354700080 * Tau)
      + 0.00000040055 * cos(5.31611875490 + 20043.67456000000 * Tau)
      + 0.00000032886 * cos(5.41067411970 +  6283.07585000000 * Tau)
      + 0.00000028244 * cos(0.04534124888 +  9492.14631500000 * Tau)
      + 0.00000026579 * cos(3.88960724780 +  1221.84856630000 * Tau)
      + 0.00000026554 * cos(5.11271747610 +  2700.71514040000 * Tau);

  L2 := 0.00058015791 * cos(2.04979463280 +  3340.61242670000 * Tau)
      + 0.00054187645 * cos(0.00000000000 +     0.00000000000 * Tau)
      + 0.00013908426 * cos(2.45742359890 +  6681.22485340000 * Tau)
      + 0.00002465104 * cos(2.80000020930 + 10021.83728000000 * Tau)
      + 0.00000398379 * cos(3.14118428290 + 13362.44970700000 * Tau)
      + 0.00000222022 * cos(3.19436080020 +     3.52311834900 * Tau)
      + 0.00000120957 * cos(0.54325292454 +   155.42039943000 * Tau)
      + 0.00000061517 * cos(3.48529427370 + 16703.06213300000 * Tau)
      + 0.00000053638 * cos(3.54191121460 +  3344.13554500000 * Tau)
      + 0.00000034268 * cos(6.00188499120 +  2281.23049650000 * Tau)
      + 0.00000031665 * cos(4.14015171790 +   191.44826611000 * Tau)
      + 0.00000029839 * cos(1.99870679840 +   796.29800682000 * Tau)
      + 0.00000023168 * cos(4.33403365930 +   242.72860397000 * Tau)
      + 0.00000021659 * cos(3.44532466380 +   398.14900341000 * Tau)
      + 0.00000020370 * cos(5.42191375400 +   553.56940284000 * Tau)
      + 0.00000016227 * cos(0.65678953303 +     0.98032106820 * Tau)
      + 0.00000016044 * cos(6.11000472440 +  2146.16541650000 * Tau)
      + 0.00000015648 * cos(1.22086121940 +  1748.01641310000 * Tau)
      + 0.00000014927 * cos(6.09541783560 +  3185.19202730000 * Tau)
      + 0.00000014416 * cos(4.01923812100 +   951.71840625000 * Tau)
      + 0.00000014317 * cos(2.61851897590 +  1349.86740970000 * Tau)
      + 0.00000013352 * cos(0.60189008414 +  1194.44701020000 * Tau)
      + 0.00000011934 * cos(3.86122163020 +  6684.74797180000 * Tau)
      + 0.00000011260 * cos(4.71822363670 +  2544.31441990000 * Tau)
      + 0.00000010396 * cos(0.25038714677 +   382.89653222000 * Tau)
      + 0.00000009468 * cos(0.68170713564 +  1059.38193020000 * Tau)
      + 0.00000009229 * cos(3.83209092320 + 20043.67456000000 * Tau)
      + 0.00000009005 * cos(3.88271826100 +  3738.76143010000 * Tau)
      + 0.00000007501 * cos(5.46498630410 +  1751.53953140000 * Tau)
      + 0.00000006859 * cos(2.57522504140 +  3149.16416060000 * Tau)
      + 0.00000006681 * cos(2.37843690340 +  4136.91043350000 * Tau)
      + 0.00000006497 * cos(5.47773072870 +  1592.59601360000 * Tau)
      + 0.00000006311 * cos(2.34104793670 +  3097.88382270000 * Tau);

  L3 := 0.00001482423 * cos(0.44434694876 +  3340.61242670000 * Tau)
      + 0.00000662095 * cos(0.88469178686 +  6681.22485340000 * Tau)
      + 0.00000188268 * cos(1.28799982500 + 10021.83728000000 * Tau)
      + 0.00000041474 * cos(1.64850787000 + 13362.44970700000 * Tau)
      + 0.00000025994 * cos(0.00000000000 +     0.00000000000 * Tau)
      + 0.00000022661 * cos(2.05267665260 +   155.42039943000 * Tau)
      + 0.00000010454 * cos(1.58006906380 +     3.52311834900 * Tau)
      + 0.00000008024 * cos(1.99858757690 + 16703.06213300000 * Tau)
      + 0.00000004900 * cos(2.82452457970 +   242.72860397000 * Tau)
      + 0.00000003782 * cos(2.01914272510 +  3344.13554500000 * Tau)
      + 0.00000003176 * cos(4.59144897930 +  3185.19202730000 * Tau)
      + 0.00000003134 * cos(0.65044714325 +   553.56940284000 * Tau);

  L4 := 0.00000113969 * cos(3.14159265360 +     0.00000000000 * Tau)
      + 0.00000028725 * cos(5.63662412040 +  6681.22485340000 * Tau)
      + 0.00000024447 * cos(5.13868481450 +  3340.61242670000 * Tau)
      + 0.00000011187 * cos(6.03161074430 + 10021.83728000000 * Tau)
      + 0.00000003252 * cos(0.13228350651 + 13362.44970700000 * Tau)
      + 0.00000003190 * cos(3.56267988300 +   155.42039943000 * Tau)
      + 0.00000000787 * cos(0.49340783377 + 16703.06213300000 * Tau)
      + 0.00000000776 * cos(1.31734531590 +   242.72860397000 * Tau);

  L5 := 0.00000000868 * cos(3.14159265360 +     0.00000000000 * Tau)
      + 0.00000000710 * cos(4.04089996520 +  6681.22485340000 * Tau);
  Result := (L0 + L1*Tau + L2*Tau2 + L3*Tau3 + L4*Tau4 + L5*Tau5);
end;

{-------------------------------------------------------------------------}

function GetLatitude(Tau, Tau2, Tau3, Tau4, Tau5 : Double) : Double;
var
  B0, B1,
  B2, B3,
  B4, B5  : Double;
begin
  B0 := 0.03197134986 * cos(3.76832042430 +  3340.61242670000 * Tau)
      + 0.00298033234 * cos(4.10616996240 +  6681.22485340000 * Tau)
      + 0.00289104742 * cos(0.00000000000 +     0.00000000000 * Tau)
      + 0.00031365538 * cos(4.44651052850 + 10021.83728000000 * Tau)
      + 0.00003484100 * cos(4.78812547890 + 13362.44970700000 * Tau)
      + 0.00000443401 * cos(5.02642620490 +  3344.13554500000 * Tau)
      + 0.00000442999 * cos(5.65233015880 +  3337.08930840000 * Tau)
      + 0.00000399109 * cos(5.13056814700 + 16703.06213300000 * Tau)
      + 0.00000292506 * cos(3.79290644590 +  2281.23049650000 * Tau)
      + 0.00000181982 * cos(6.13648011700 +  6151.53388830000 * Tau)
      + 0.00000163159 * cos(4.26399626630 +   529.69096509000 * Tau)
      + 0.00000159678 * cos(2.23194610250 +  1059.38193020000 * Tau)
      + 0.00000149297 * cos(2.16501209920 +  5621.84292320000 * Tau)
      + 0.00000142686 * cos(1.18215016110 +  3340.59517300000 * Tau)
      + 0.00000142685 * cos(3.21292180820 +  3340.62968040000 * Tau)
      + 0.00000139323 * cos(2.41796344240 +  8962.45534990000 * Tau);

  B1 := 0.00350068845 * cos(5.36847836210 +  3340.61242670000 * Tau)
      + 0.00014116030 * cos(3.14159265360 +     0.00000000000 * Tau)
      + 0.00009670755 * cos(5.47877786510 +  6681.22485340000 * Tau)
      + 0.00001471918 * cos(3.20205766790 + 10021.83728000000 * Tau)
      + 0.00000425864 * cos(3.40843812880 + 13362.44970700000 * Tau)
      + 0.00000102039 * cos(0.77617286189 +  3337.08930840000 * Tau)
      + 0.00000078848 * cos(3.71768293870 + 16703.06213300000 * Tau)
      + 0.00000032708 * cos(3.45803723680 +  5621.84292320000 * Tau)
      + 0.00000026171 * cos(2.48293558070 +  2281.23049650000 * Tau);

  B2 := 0.00016726690 * cos(0.60221392419 +  3340.61242670000 * Tau)
      + 0.00004986799 * cos(3.14159265360 +     0.00000000000 * Tau)
      + 0.00000302141 * cos(5.55871276020 +  6681.22485340000 * Tau)
      + 0.00000025767 * cos(1.89662673500 + 13362.44970700000 * Tau)
      + 0.00000021452 * cos(0.91749968618 + 10021.83728000000 * Tau)
      + 0.00000011820 * cos(2.24240738700 +  3337.08930840000 * Tau)
      + 0.00000007985 * cos(2.24892866610 + 16703.06213300000 * Tau);

  B3 := 0.00000606506 * cos(1.98050633530 +  3340.61242670000 * Tau)
      + 0.00000042611 * cos(0.00000000000 +     0.00000000000 * Tau)
      + 0.00000013652 * cos(1.79588228800 +  6681.22485340000 * Tau)
      + 0.00000002730 * cos(3.45377082120 + 10021.83728000000 * Tau);

  B4 := 0.00000013369 * cos(0.00000000000 +     0.00000000000 * Tau)
      + 0.00000011334 * cos(3.45724352590 +  3340.61242670000 * Tau)
      + 0.00000000744 * cos(0.50445805257 +  6681.22485340000 * Tau);

  B5 := 0.00000000000;
  Result := (B0 + B1*Tau + B2*Tau2 + B3*Tau3 + B4*Tau4 + B5*Tau5);
end;

{-------------------------------------------------------------------------}

function GetRadiusVector(Tau, Tau2, Tau3, Tau4, Tau5 : Double) : Double;
var
  R0, R1,
  R2, R3,
  R4, R5  : Double;
begin
  R0 := 1.53033488280 * cos(0.00000000000 +     0.00000000000 * Tau)
      + 0.14184953153 * cos(3.47971283520 +  3340.61242670000 * Tau)
      + 0.00660776357 * cos(3.81783442100 +  6681.22485340000 * Tau)
      + 0.00046179117 * cos(4.15595316280 + 10021.83728000000 * Tau)
      + 0.00008109738 * cos(5.55958460170 +  2810.92146160000 * Tau)
      + 0.00007485315 * cos(1.77238998070 +  5621.84292320000 * Tau)
      + 0.00005523193 * cos(1.36436318880 +  2281.23049650000 * Tau)
      + 0.00003825160 * cos(4.49407182410 + 13362.44970700000 * Tau)
      + 0.00002484385 * cos(4.92545577890 +  2942.46342330000 * Tau)
      + 0.00002306539 * cos(0.09081742493 +  2544.31441990000 * Tau)
      + 0.00001999399 * cos(5.36059605230 +  3337.08930840000 * Tau)
      + 0.00001960198 * cos(4.74249386320 +  3344.13554500000 * Tau)
      + 0.00001167115 * cos(2.11261501150 +  5092.15195810000 * Tau)
      + 0.00001102828 * cos(5.00908264160 +   398.14900341000 * Tau)
      + 0.00000992252 * cos(5.83862401070 +  6151.53388830000 * Tau)
      + 0.00000899077 * cos(4.40790433990 +   529.69096509000 * Tau)
      + 0.00000807348 * cos(2.10216647100 +  1059.38193020000 * Tau)
      + 0.00000797910 * cos(3.44839026170 +   796.29800682000 * Tau)
      + 0.00000740980 * cos(1.49906336890 +  2146.16541650000 * Tau)
      + 0.00000725583 * cos(1.24516913470 +  8432.76438480000 * Tau)
      + 0.00000692340 * cos(2.13378814790 +  8962.45534990000 * Tau)
      + 0.00000633144 * cos(0.89353285018 +  3340.59517300000 * Tau)
      + 0.00000633140 * cos(2.92430448170 +  3340.62968040000 * Tau)
      + 0.00000629976 * cos(1.28738135860 +  1751.53953140000 * Tau)
      + 0.00000574352 * cos(0.82896196337 +  2914.01423580000 * Tau)
      + 0.00000526187 * cos(5.38292276230 +  3738.76143010000 * Tau)
      + 0.00000472776 * cos(5.19850457870 +  3127.31333130000 * Tau)
      + 0.00000348095 * cos(4.83219198910 + 16703.06213300000 * Tau)
      + 0.00000283702 * cos(2.90692294910 +  3532.06069280000 * Tau)
      + 0.00000279552 * cos(5.25749247550 +  6283.07585000000 * Tau)
      + 0.00000275501 * cos(1.21767967780 +  6254.62666250000 * Tau)
      + 0.00000275224 * cos(2.90818883830 +  1748.01641310000 * Tau)
      + 0.00000269891 * cos(3.76394728620 +  5884.92684660000 * Tau)
      + 0.00000239133 * cos(2.03669896240 +  1194.44701020000 * Tau)
      + 0.00000233827 * cos(5.10546492530 +  5486.77784320000 * Tau)
      + 0.00000228128 * cos(3.25529020620 +  6872.67311950000 * Tau)
      + 0.00000223190 * cos(4.19861593780 +  3149.16416060000 * Tau)
      + 0.00000219428 * cos(5.58340248780 +   191.44826611000 * Tau)
      + 0.00000208336 * cos(4.84626442120 +  3340.67973700000 * Tau)
      + 0.00000208333 * cos(5.25476080770 +  3340.54511640000 * Tau)
      + 0.00000186213 * cos(5.69871555750 +  6677.70173500000 * Tau)
      + 0.00000182686 * cos(5.08062683360 +  6684.74797180000 * Tau)
      + 0.00000178613 * cos(4.18423025540 +  3333.49887970000 * Tau)
      + 0.00000175995 * cos(5.95341786370 +  3870.30339180000 * Tau)
      + 0.00000163534 * cos(3.79889068110 +  4136.91043350000 * Tau);

  R1 := 0.01107433340 * cos(2.03250524950 +  3340.61242670000 * Tau)
      + 0.00103175886 * cos(2.37071845680 +  6681.22485340000 * Tau)
      + 0.00012877200 * cos(0.00000000000 +     0.00000000000 * Tau)
      + 0.00010815880 * cos(2.70888093800 + 10021.83728000000 * Tau)
      + 0.00001194550 * cos(3.04702182500 + 13362.44970700000 * Tau)
      + 0.00000438579 * cos(2.88835072630 +  2281.23049650000 * Tau)
      + 0.00000395698 * cos(3.42324611290 +  3344.13554500000 * Tau)
      + 0.00000182572 * cos(1.58428644000 +  2544.31441990000 * Tau)
      + 0.00000135850 * cos(3.38507017990 + 16703.06213300000 * Tau)
      + 0.00000128362 * cos(6.04343360440 +  3337.08930840000 * Tau)
      + 0.00000128204 * cos(0.62991220570 +  1059.38193020000 * Tau)
      + 0.00000127068 * cos(1.95389775740 +   796.29800682000 * Tau)
      + 0.00000118443 * cos(2.99761345070 +  2146.16541650000 * Tau)
      + 0.00000087537 * cos(3.42052758980 +   398.14900341000 * Tau)
      + 0.00000083026 * cos(3.85574986650 +  3738.76143010000 * Tau)
      + 0.00000075598 * cos(4.45101839350 +  6151.53388830000 * Tau)
      + 0.00000071999 * cos(2.76442180680 +   529.69096509000 * Tau)
      + 0.00000066542 * cos(2.54892602690 +  1751.53953140000 * Tau)
      + 0.00000066430 * cos(4.40597549960 +  1748.01641310000 * Tau)
      + 0.00000057518 * cos(0.54354327916 +  1194.44701020000 * Tau)
      + 0.00000054314 * cos(0.67750943459 +  8962.45534990000 * Tau)
      + 0.00000051035 * cos(3.72585409210 +  6684.74797180000 * Tau)
      + 0.00000049428 * cos(5.72959428360 +  3340.59517300000 * Tau)
      + 0.00000049424 * cos(1.47717922230 +  3340.62968040000 * Tau)
      + 0.00000048318 * cos(2.58061691300 +  3149.16416060000 * Tau)
      + 0.00000047863 * cos(2.28527896840 +  2914.01423580000 * Tau)
      + 0.00000038953 * cos(2.31900090550 +  4136.91043350000 * Tau);

  R2 := 0.00044242247 * cos(0.47930603943 +  3340.61242670000 * Tau)
      + 0.00008138042 * cos(0.86998398093 +  6681.22485340000 * Tau)
      + 0.00001274915 * cos(1.22594050810 + 10021.83728000000 * Tau)
      + 0.00000187387 * cos(1.57298991980 + 13362.44970700000 * Tau)
      + 0.00000052396 * cos(3.14159265360 +     0.00000000000 * Tau)
      + 0.00000040744 * cos(1.97080175060 +  3344.13554500000 * Tau)
      + 0.00000026616 * cos(1.91665615760 + 16703.06213300000 * Tau)
      + 0.00000017825 * cos(4.43499505330 +  2281.23049650000 * Tau)
      + 0.00000011713 * cos(4.52510453730 +  3185.19202730000 * Tau)
      + 0.00000010209 * cos(5.39143469550 +  1059.38193020000 * Tau)
      + 0.00000009950 * cos(0.41870577185 +   796.29800682000 * Tau);

  R3 := 0.00001113107 * cos(5.14987350140 +  3340.61242670000 * Tau)
      + 0.00000424446 * cos(5.61343766480 +  6681.22485340000 * Tau)
      + 0.00000100044 * cos(5.99726827030 + 10021.83728000000 * Tau)
      + 0.00000019606 * cos(0.07633062094 + 13362.44970700000 * Tau)
      + 0.00000004693 * cos(3.14159265360 +     0.00000000000 * Tau)
      + 0.00000003477 * cos(0.42951907576 + 16703.06213300000 * Tau);

  R4 := 0.00000019552 * cos(3.58211650470 +  3340.61242670000 * Tau)
      + 0.00000016323 * cos(4.05116076920 +  6681.22485340000 * Tau)
      + 0.00000005848 * cos(4.46383962090 + 10021.83728000000 * Tau)
      + 0.00000001532 * cos(4.84374321620 + 13362.44970700000 * Tau);

  R5 := 0.00000000000;
  Result := (R0 + R1*Tau + R2*Tau2 + R3*Tau3 + R4*Tau4 + R5*Tau5);
end;

{-------------------------------------------------------------------------}

function ComputeMars(JD : Double) : TStEclipticalCord;
var
  Tau,
  Tau2,
  Tau3,
  Tau4,
  Tau5      : Double;
begin
  Tau  := (JD - 2451545.0) / 365250.0;
  Tau2 := sqr(Tau);
  Tau3 := Tau * Tau2;
  Tau4 := sqr(Tau2);
  Tau5 := Tau2 * Tau3;

  Result.L0 := GetLongitude(Tau, Tau2, Tau3, Tau4, Tau5);
  Result.B0 := GetLatitude(Tau, Tau2, Tau3, Tau4, Tau5);
  Result.R0 := GetRadiusVector(Tau, Tau2, Tau3, Tau4, Tau5);
end;


end.
